<!--
 * @Author: your name
 * @Date: 2021-11-10 18:40:05
 * @LastEditTime: 2021-11-10 19:07:58
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue-note\day01\09.todolist简单.html
-->
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>09.todolist简单</title>
    <style>
      .item {
        color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      {{msg}}
      <div>
        <input type="text" v-model="info" />
        <button @click="handleClick">添加</button>
      </div>
      <ul>
        <Item v-for="item in list" :item="item"></Item>
      </ul>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
    <script>
      Vue.component("Item", {
        props: ["item"],
        template: "<li class='item'>{{item}}</li>",
      });
      new Vue({
        el: "#app",
        data() {
          return {
            msg: "hello",
            info: "",
            list: [],
          };
        },
        methods: {
          handleClick() {
            console.log(this.info);
            this.list.push(this.info);
            this.info = "";
          },
        },
      });
    </script>
  </body>
</html>
